/**
 * 前台个人账号界面整体管理JS文件
 * @author huangwm210 2009-01-20
 */
 
var $j = jQuery.noConflict();
cs = function(){}
cs.val = {
	addressList: __ctxPath+"/customer/csAddressList.html",
	addressForm:__ctxPath+"/customer/csEditAddress.html",
	wishListForm:__ctxPath+"/customer/wishlistEdit.html",
	wishList:__ctxPath+"/customer/wishlistManage.html"
}
cs.util = {
  go:function(url){
	window.location.href = url
  }
}
cs.util.effect = {
	effectShow:function(jObj,w,h){
    	if(jObj.css("display")=="none"){
    	   jObj.height(0);jObj.width(0)
    	}
    	jObj.animate({width:w},{queue: true, duration: "fast"})
				.animate({height:h},{queue: true, duration: "fast"})
    },
	effectHide:function(jObj){
		var h = jObj.height();
		var w = jObj.width();
		if(jObj.css("display")=="none"){
    	   return ;
    	}
		jObj.animate({height:0},{queue: true, duration: "fast"})
			.animate({width:0},{queue: true, duration: "fast",complete:function(){
			    	jObj.hide();jObj.height(h);jObj.width(w);
			    }})
	},
	hideMsg:function(){
		var msg = $j("#_sys_msg_");
	    this.effectHide(msg);
	}
}

/**
 * 个人地址操作类
 */
cs.address = {
	/**
	 * 将某个地址设置为默认的
	 */
	defaultAd:function(id){
		myAccountDwr.updateAddressAsDefault(id,function(data){
			cs.util.go(cs.val.addressList);
		})
    },
	/**
	 * 将某个地址删除
	 */
	deleteAdd:function(id){
		if(confirm(__FMT.addressDelete)){
			myAccountDwr.delAddress(id,function(data){
			  cs.util.go(cs.val.addressList);
			})
	    }
	},
	/**
	 * 进入编辑页面
	 */
	edit:function(id){
	
	  $j('<form style="display: none;" action="'+cs.val.addressForm+'" method="POST"><input name="addressId" type="text" value="'+id+'"><input name="from" value="list"></form>').appendTo('body').submit();
	}
}
/**
 * 意愿清单管理类
 */
cs.wishList = {
	edit:function(id){
		$j('<form style="display: none;" target="_self"  action="'+cs.val.wishListForm+'" method="post"><input name="wishListId" type="text" value="'+id+'"><input name="from" type="hidden" value="list"></form>').appendTo("body").submit();
	},
	del:function(id){
		if(window.confirm(__FMT.deletedConfirm))
		  $j('<form style="display: none;" action="'+cs.val.wishList+'" method="POST"><input name="wishlistId" type="text" value="'+id+'"><input name="doAction" value="deleteWishlist"></form>').appendTo('body').submit();
		else
		  return false;
	},
	setDefault:function(id){
		myAccountDwr.setWishListAsDefault(id,function(data){
			cs.util.go(cs.val.wishList);
		})
	}
}
$j(document).ready(function(){
	var msg = $j("#_sys_msg_");
	if(msg.length>0){
		setTimeout('cs.util.effect.hideMsg()',5000);
	}
})
